package day11.setdemo;

import redis.clients.jedis.Jedis;

import java.util.Random;


/**
 * 看每个英雄的出场次数。
 *
 */
public class LolBoxPlayer {
    private static Jedis jedis = new Jedis("master", 6379);

    public static void main(String[] args) throws InterruptedException {
        Random r = new Random();
        String[] heros = {"盖伦", "女警", "小炮", "诺手", "提莫", "狗头"};

        while (true){
            int index = r.nextInt(heros.length);
            String hero = heros[index];
            Thread.sleep(2000);
            // 给英雄每次出场的分数加1，如果初次出场，zincrby方法会自动创建
            jedis.zincrby("hero:ccl", 1, hero);
            System.out.println(hero + " 出场了");

        }

    }

}
